package com.handy.socket.demo;

import org.apache.log4j.Logger;

import com.handy.socket.HttpConnection;

public class HttpConnectionDemo {

    public HttpConnectionDemo() {
        super();
    }

    public static void main(String[] args) {
    	HttpConnection hc = new  HttpConnection();
    	
    	//下载网页内容
//    	String url = "http://202.103.25.191/mreader/index/readerindex.action";
    	//String url = "http://192.168.18.15/mreader/index/readerindex.action";
    	//String url = "http://192.168.0.1/mreader/index/readerindex.action";
//    	String param = "v=1.0&index=3";
//    	hc.setRequestMethod(HttpConnection.REQUEST_METHOD_GET);
//    	hc.setUrl(url);
//    	hc.setParam(param);
//    	hc.setCharset("utf-8");
//        String str = hc.getHttpText();
//        log.info(str);
    	
    	//下载文件
//    	String srcFile = "http://59.151.39.10/moscreen_pic/2010/01/08/20100108162017xrexofydrc176x208.jpg";
//    	String destFile = "d:\\20100108162017.jpg";
//    	log.info("正在下载文件："+srcFile);
//    	hc.getFile(srcFile, destFile);
//    	log.info("下载完成，保存在："+destFile);
    	
    	//访问wap
    	hc.setRequestProperty("text/vnd.wap.wml,text/vnd.wap.wmlscript,image/vnd.wap.wbmp");
    	String url = "http://wap.moscreen.cn/include/bottom/mohave3.jsp?offset=12&class_id=325&soft_group_id=002&magazine_id=2354";
    	hc.setUrl(url);
    	hc.setRequestMethod(HttpConnection.REQUEST_METHOD_GET);
    	hc.setCharset("utf-8");
    	String str = hc.getHttpText();
    	log.info(str);
    }
    
    private static Logger log = Logger.getLogger(HttpConnectionDemo.class);
}
